package com.gexiaobao.pigeon.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.RaceVoucherResponse
import com.gexiaobao.pigeon.databinding.ItemRelatedDoctmentBinding

/**
 * @Author      : hxw
 * @Date        : 2024/3/28 10:28
 * @Describe    :
 */
class RelatedDocumentAdapter(data: ArrayList<RaceVoucherResponse.ListBean.ListBeanRelated>) :
    BaseQuickAdapter<RaceVoucherResponse.ListBean.ListBeanRelated, DataBindBaseViewHolder>(R.layout.item_related_doctment, data) {

    private var onRelatedClickListener: OnRelatedClickListener? = null

    override fun convert(holder: DataBindBaseViewHolder, item: RaceVoucherResponse.ListBean.ListBeanRelated) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemRelatedDoctmentBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        holder.itemView.setOnClickListener {
            onRelatedClickListener?.onItemClick(holder.layoutPosition, item.path, item.name)
        }
    }

    fun setOnRelatedClickListener(listener: OnRelatedClickListener?) {
        onRelatedClickListener = listener
    }

    interface OnRelatedClickListener {
        fun onItemClick(position: Int, path: String, name: String)
    }

}